﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Shell;
using VocabManager.ViewModel;

namespace VocabManager.View
{
    public partial class DeckViewEdit : UserControlBase  
    {
        ApplicationBarIconButton _cancel;
        ApplicationBarIconButton _save;
        DeckViewModel _deckViewModel;
        public DeckViewEdit()
        {
            InitializeComponent();

            _cancel = new ApplicationBarIconButton(new Uri(IconUrls.Cancel, UriKind.Relative));
            _cancel.Click += new EventHandler(_cancel_Click);
            _cancel.Text = "cancel";


            _save = new ApplicationBarIconButton(new Uri(IconUrls.Save, UriKind.Relative));
            _save.Text = "save";
            _save.Click += new EventHandler(_save_Click);

        }

        void _save_Click(object sender, EventArgs e)
        {
            _deckViewModel.SaveCommand.Execute(null);
        }

        void _cancel_Click(object sender, EventArgs e)
        {
            _deckViewModel.CancelEditCommand.Execute(null);
        }

        protected override void OnLoad()
        {
            base.OnLoad();
            _deckViewModel = this.DataContext as DeckViewModel;
            StoreAppBarButtons();
            ContainerPage.ApplicationBar.Buttons.Clear();

 

            ContainerPage.ApplicationBar.Buttons.Add(_save);
            ContainerPage.ApplicationBar.Buttons.Add(_cancel);



        }

      
        

        
    }

}
